package com.example.string;

/**
 * 验证switch中传入null会出现  NullPointerException异常，所以用switch业务逻辑时，要先判空
 */
public class SwitchMore {
    public static void main(String[] args) {
        int value = 1;
        switch (value) {
            case 1:
            case 2:
                System.out.println("Value is 222");
            case 3:
                System.out.println("Value is 1, 2, or 3");
                break;
            case 4:
            case 5:
            case 6:
                System.out.println("Value is 4, 5, or 6");
                break;
            default:
                System.out.println("Value is not in the specified range");
        }
    }

}
